package com.zuoyy.modules.system.domain;

import com.zuoyy.modules.common.DataEntity;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author 
 */
@Data
@Entity
@Table(name="sys_dept")
@EntityListeners(AuditingEntityListener.class)
public class Dept extends DataEntity implements Serializable {
    // 部门名称
    private String deptName;
    // 父id
    private String pid;

    private String pids;
    // 顺序
    private Integer sort;

    @Transient
    private List<Dept> children = new ArrayList<>();


    public void setPids(String pids) {
        if (pids.startsWith(",")){
            pids = pids.substring(1);
        }
        this.pids = pids;
    }
}